package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;

public class DrawBitmap extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}

	class MyView extends View {

		private Paint paint;
		private Bitmap bit;

		public MyView(Context context) {
			super(context);
			paint = new Paint(Paint.ANTI_ALIAS_FLAG);
			bit = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			canvas.drawBitmap(bit, 10, 10, null);
			canvas.drawBitmap(bit, null, new Rect(150, 10, 200, 85), null);
			canvas.drawBitmap(bit, new Rect(30, 30, 70, 80), new Rect(210, 10, 210+80, 10+100), null);
		}
	}
}
